'use strict';
// Copyright 2014 Blueant Inc. All Rights Reserved.

/**
 * @fileoverview 任务配置
 * @author sundbcn@gmail.com (sun debing)
 */

var dataApi = require('../libs/dataApi');
var _ = require('lodash');
/**
 * 获取任务配置
 * @param  {[type]} mission_id [description]
 * @return {[type]}            [description]
 */

exports.getMissionConf = function (mission_id) {
    var mission_conf = dataApi.mission.findById(mission_id);
    return mission_conf;
};

exports.getMissionRewardConf = function (job_type) {
    var mission_reward_conf = dataApi.mission_reward.findById(job_type);
    return mission_reward_conf;
};

var next_mission_reward_map = {};
exports.getNewMissionRewardConf = function (job_type, mission_id) {
    var key = mission_id * 100 + job_type;
    if (key in next_mission_reward_map) {
        return next_mission_reward_map[key];
    }

    var mission_reward_conf = dataApi.mission_reward.findById(mission_id);
    var reward_list = [];
    _.each(mission_reward_conf, function (value) {
        if (value.job_type === job_type) {
            reward_list.push(value);
        }
    });
    next_mission_reward_map[key] = reward_list;
    return reward_list;
};
